<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	 <meta charset="UTF-8">
	 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	 <title th:replace="common/base::pagetitle"></title>
	 <link th:replace="common/base::static"/>
	 <link rel="shortcut icon" href="图标地址" type="image/x-icon">
</head>
<body style="background-color: #afb6c5">
<div class="wlb-user-login" id="kUserLoginBox">
	 
	 <div class="wlb-user-login-main">
		  <div class="wlb-user-login-box wlb-user-login-header">
				<h2>微利宝运营平台</h2>
		  </div>
		  <div class="layui-form wlb-user-login-box">
				<div class="layui-form-item">
					 <label class="wlb-user-login-icon layui-icon layui-icon-username" for="kUserLoginUsername"></label>
					 <input type="text" name="username" id="kUserLoginUsername" lay-verify="required" placeholder="用户名" class="layui-input">
				</div>
				<div class="layui-form-item">
					 <label class="wlb-user-login-icon layui-icon layui-icon-password" for="kUserLoginPassword"></label>
					 <input type="password" name="password" id="kUserLoginPassword" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-item">
					 <div class="layui-row">
						  <div class="layui-col-xs7">
								<label class="wlb-user-login-icon layui-icon layui-icon-vercode" for="kUserLoginVercode"></label>
								<input type="text" name="vercode" id="kUserLoginVercode" placeholder="图形验证码" class="layui-input">
						  </div>
						  <div class="layui-col-xs5">
								<div style="margin-left: 10px;">
									 <img th:src="@{/captcha.jpg}" class="wlb-user-login-codeimg" id="kUserGetVerCode" title="点击刷新验证码">
								</div>
						  </div>
					 </div>
				</div>
				<div class="layui-form-item" style="margin-bottom: 20px;">
					 <input type="checkbox" name="rememberMe" lay-skin="primary" title="记住密码">
					 <a href="forget.html" class="wlb-user-jump-change" style="margin-top: 7px;">忘记密码？</a>
				</div>
				<div class="layui-form-item">
					 <button id="submitBtn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="kUserLoginSubmit">登 入</button>
				</div>
				<!--<div class="layui-trans layui-form-item layadmin-user-login-other">
					 <label>社交账号登入</label>
					 <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
					 <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
					 <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>

					 <a href="reg.html" class="layadmin-user-jump-change layadmin-link">注册帐号</a>
				</div>-->
		  </div>
	 </div>
	 
	 <div class="layui-trans wlb-user-login-footer">
		  <p>© 2020 <a href="https://tools.kalvinbg.cn" target="_blank">http://wwww.wlb365.com</a></p>
	 </div>

</div>

<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>
<script>
    layui.use('form', function () {
        var form = layui.form;

        //提交
        form.on('submit(kUserLoginSubmit)', function (obj) {
            //请求登入接口
            wlbKit.aPost(api.login, obj.field, function (r) {
                if (r.code === req.status.ok) {
                    // // todo 请求成功后，写入 access_token
                    // layui.data(setter.tableName, {
                    //     key: setter.request.tokenName
                    //     ,value: res.data.access_token
                    // });
                    // 登入成功的提示与跳转
                    layer.msg('登录成功', {
                        offset: '15px'
                        , icon: 1
                        , time: 500
                    }, function () {
                        location.href = api.homeView; // 首页
                    });

                } else {
                    if (r.msg.indexOf('验证码') !== -1) {
                        wlbKit.errorMsg(r.msg + '，请重试。');
                        refreshVerCode();
                    } else {
                        wlbKit.errorMsg(r.msg);
                        refreshVerCode();
                    }
                }
            });
        });

        // 绑定监听回车事件
        wlbKit.bindEnterEventForLayuiForm();


        $('#kUserGetVerCode').on('click', function () {
            refreshVerCode();
        });

        // 刷新图片验证码
        function refreshVerCode() {
            $('#kUserGetVerCode').attr('src', api.captchaUrl);
        }

    })
</script>
</body>
</html>